package com.qingke.test;

public class Account {
	private String id;
	private String name;
	private int balance;
	
	
	public Account(String id,String name){
		this.id=id;
		this.name=name;
	}
	public Account(String id,String name,int balance){
		this.id=id;
		this.name=name;
		this.balance=balance;
	}
	public String geId(){
		return id;
	}
	public String getName(){
		return name;
	}
	public int getBalance(){
		return balance;
	}
	public int creadit(int amount){
		balance+=amount;
		return balance;
	}
	public int debit(int amount){
		if(amount<=balance)
			balance-=amount;
		else{
			System.out.println("Amount exceeded balance");
		}
		return balance;
	}
	public int transferTo(Account another,int amount){
		if(amount<=balance){
			balance-=amount;
			another.creadit(amount);
		}
		else
			System.out.println("Amount exceeded balance");
		return balance;
	}
	public String toString(){
		String str="Account[id="+id+",name="+name+",balance="+balance+"]";
		return str;
	}
	
}
